package fr.umlv.jee.jawp.service.configuration;

import java.util.LinkedList;
import java.util.List;

import org.jawp.persistence.Order;
import org.jawp.persistence.OrderDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;

@Service("OrderService")
public class OrderService {
	@Autowired
	private OrderDAO dao;
	
	/*************************************
	 *				Creation
	 *************************************/

	@Transactional
	public Order createNewOrder(int customerId) {
		return dao.createNewOrder(customerId);
	}

	/*************************************
	 *				Getter
	 *************************************/

	@Transactional(readOnly = true)
	public List<Order> getOrders() {		 
		return dao.getOrders();
	}

	@Transactional(readOnly = true)
	public List<Order> getOrdersByCustomer(int customerId) {		 
		return dao.getOrdersByCustomer(customerId);
	}

	@Transactional(readOnly = true)
	public Order getOrderById(int id) {		 
		return dao.getOrderById(id);
	}

	/*************************************
	 *				Setter
	 *************************************/

	/*************************************
	 *				Deletion
	 *************************************/

	@Transactional
	public void deleteOrder(int id) {
		dao.deleteOrder(id);
	}

	@Transactional
	public void deleteOrdersByCustomer(int customerId) {
		dao.deleteOrdersByCustomer(customerId);
	}
}
